<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of BookingPayment
 *
 * @author fabiano
 */
class BookingPayment {
    
        public $name_credit_card_holder;
        public $credit_card_type;
        public $credit_card_number;
        public $credit_card_expiry_month;
        public $credit_card_expiry_year;
        public $credit_card_security_code;
        public $address_1;
        public $address_2;
        public $town;
        public $county;
        //public $country;
        public $booking_id;
        public $booking_payment_id;
        
        function __construct($params) {
            if ($params != NULL){
                $this->setBooking_id($params['booking_id']);
                $this->setName_credit_card_holder($params["name_credit_card_holder"]);
                $this->setCredit_card_type($params["credit_card_type"]);
                $this->setCredit_card_number($params["credit_card_number"]);
                $this->setCredit_card_expiry_month($params["credit_card_expiry_month"]);
                $this->setCredit_card_expiry_year($params["credit_card_expiry_year"]);
                $this->setCredit_card_security_code($params["credit_card_security_code"]);
                $this->setAddress_1($params["address_1"]);
                $this->setAddress_2($params["address_2"]);
                $this->setTown($params["town"]);
                $this->setCounty($params["county"]);
                //$this->setCountry( $params["country"]);
            }            

        }

        public function getBooking_id() {
            return $this->booking_id;
        }

        public function setBooking_id($booking_id) {
            $this->booking_id = $booking_id;
        }

        public function getBooking_payment_id() {
            return $this->booking_payment_id;
        }

        public function setBooking_payment_id($booking_payment_id) {
            $this->booking_payment_id = $booking_payment_id;
        }

                
        public function getName_credit_card_holder() {
            return $this->name_credit_card_holder;
        }

        public function setName_credit_card_holder($name_credit_card_holder) {
            $this->name_credit_card_holder = $name_credit_card_holder;
        }

        public function getCredit_card_type() {
            return $this->credit_card_type;
        }

        public function setCredit_card_type($credit_card_type) {
            $this->credit_card_type = $credit_card_type;
        }

        public function getCredit_card_number() {
            return $this->credit_card_number;
        }

        public function setCredit_card_number($credit_card_number) {
            $this->credit_card_number = substr($credit_card_number, strlen($credit_card_number) - 4);
        }

        public function getCredit_card_expiry_month() {
            return $this->credit_card_expiry_month;
        }

        public function setCredit_card_expiry_month($credit_card_expiry_month) {
            $this->credit_card_expiry_month = $credit_card_expiry_month;
        }

        public function getCredit_card_expiry_year() {
            return $this->credit_card_expiry_year;
        }

        public function setCredit_card_expiry_year($credit_card_expiry_year) {
            $this->credit_card_expiry_year = $credit_card_expiry_year;
        }

        public function getCredit_card_security_code() {
            return $this->credit_card_security_code;
        }

        public function setCredit_card_security_code($credit_card_security_code) {
            $this->credit_card_security_code = $credit_card_security_code;
        }

        public function getAddress_1() {
            return $this->address_1;
        }

        public function setAddress_1($address_1) {
            $this->address_1 = $address_1;
        }

        public function getAddress_2() {
            return $this->address_2;
        }

        public function setAddress_2($address_2) {
            $this->address_2 = $address_2;
        }

        public function getTown() {
            return $this->town;
        }

        public function setTown($town) {
            $this->town = $town;
        }

        public function getCounty() {
            return $this->county;
        }

        public function setCounty($county) {
            $this->county = $county;
        }
/*
        public function getCountry() {
            return $this->country;
        }

        public function setCountry($country) {
            $this->country = $country;
        }
        */
        public function save(){

            $sql = "INSERT INTO booking_payment SET ".make_set_clause(objectToArray($this));  
            error_log("[BookingPayment.class] - save " .$sql);
            $result = mysql_query($sql) or die (mysql_error());
            $this->booking_payment_id = mysql_insert_id();  
        }
        


}

?>
